package com.xgggh.redpack;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.databinding.DataBindingUtil;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.tencent.bugly.beta.Beta;
import com.xgggh.app.RxBaseActivity;
import com.xgggh.redpack.databinding.ActivityCameraBinding;
import com.xgggh.redpack.databinding.ActivityStartBinding;

import static android.Manifest.permission.CAMERA;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;

/**
 * @Title 红包启动页
 */
public class StartActivity extends RxBaseActivity {
    ActivityStartBinding mBinding;

    private final int REQUEST_WRITE_EXTERNAL_STORAGE=0x120;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding= DataBindingUtil.setContentView(this,R.layout.activity_start);
        if (!isTaskRoot()){
            finish();
        }
        //setSupportActionBar(mBinding.toolBarParent.toolbar);
        // https://bugly.qq.com/docs/user-guide/advance-features-android-beta/
        // 手动升级检查
        //参数1：isManual 用户手动点击检查，非用户点击操作请传false
        //参数2：isSilence 是否显示弹窗等交互，[true:没有弹窗和toast] [false:有弹窗或toast]
        Beta.checkUpgrade(false,false);
    }

    public void HomeClick(View view) {
        startActivity(new Intent(this,WeexActivity.class));
    }


    @Override
    protected void onStart() {
        super.onStart();
        mayRequestPermissions(WRITE_EXTERNAL_STORAGE,REQUEST_WRITE_EXTERNAL_STORAGE);
    }

    /**
     * Callback received when a permissions request has been completed.
     */
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                           @NonNull int[] grantResults) {
        if (requestCode == REQUEST_WRITE_EXTERNAL_STORAGE) {
            if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                //startScan();
            }
        }
    }




}
